package com.xunk.system;

import com.xunk.common.security.annotation.EnableCustomConfig;
import com.xunk.common.security.annotation.EnableRyFeignClients;
import com.xunk.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * 系统模块
 * 
 * @author ruoyi
 */
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringCloudApplication
public class XunkSystemApplication
{
//    @Bean
//    public ServletListenerRegistrationBean servletListenerRegistrationBean(){
//        ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
//        servletListenerRegistrationBean.setListener(new ClassLoaderLeakPreventor());
//        return servletListenerRegistrationBean;
//    }
    public static void main(String[] args)
    {
        SpringApplication.run(XunkSystemApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  系统模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "    __    _                 \n" +
                "   / /_  (_)___  ____ _____ \n" +
                "  / __ \\/ / __ \\/ __ `/ __ \\\n" +
                " / /_/ / / / / / /_/ / /_/ /\n" +
                "/_.___/_/_/ /_/\\__, /\\____/ \n" +
                "              /____/        \n");
    }

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //文件最大
        factory.setMaxFileSize(DataSize.ofBytes(2147483648L)); //KB,MB
        /// 设置总上传数据总大小
        factory.setMaxRequestSize(DataSize.ofBytes(2147483648L));
        return factory.createMultipartConfig();
    }
}
